package com.njit.WeStudy.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * @author 小螃蟹
 * @date 2020/1/23
 * @description 全局异常捕捉
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = MaxUploadSizeExceededException.class)
    public String MaxUploadSizeHandler(HttpServletRequest request, HttpServletResponse response, Exception e) {
        return "上传文件大小不能超过20M";
    }
}
